//引入fonts字体图标
require('../assets/fonts/iconfont.css');

//封装tabber渲染函数
function renderTabber(pathname) {

    let arr = [{
            path: './home.html',
            title: '首页',
            icon: 'icon-home'
        },
        {
            path: './run.html',
            title: '运动',
            icon: 'icon-motion'
        },
        {
            path: './circle.html',
            title: '圈子',
            icon: 'icon-circle'
        },
        {
            path: './mine.html',
            title: '我的',
            icon: 'icon-mine'
        },
        {
            path: './login.html',
            title: '登录',
            icon: 'icon-login'
        }
    ]

    let html = `
        ${arr.map((v,i)=>{
            return `<a href="${v.path}" class="item df fdc aic ${v.path === `./${pathname}.html` && 'active'}">
            <span class="iconfont ${v.icon}"></span>
            <span>${v.title}</span>
        </a>`
        }).join('')
    }
    `
    //创建div
    let div = document.createElement('div');
    //设置div的class
    div.className = 'tabbar fn df jcsb aic';
    //给div填充内容
    div.innerHTML = html;
    //body将div添加到最后
    document.body.appendChild(div);
}

//导出tabber渲染函数
module.exports = renderTabber;